package com.bing.bean.weixin;

import com.bing.utils.MsgTypeAdapter;
import com.bing.utils.StringDataAdapter;

import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.List;

/**
 * Created by kaibb on 2014/11/30.
 */
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class ResponseMessage {
    @XmlTransient
    private int id;

    @XmlTransient
    private String command;
    // 接收方帐号（收到的OpenID）
    @XmlJavaTypeAdapter(StringDataAdapter.class)
    @XmlElement(name = "ToUserName")
    private String toUserName;
    // 开发者微信号
    @XmlJavaTypeAdapter(StringDataAdapter.class)
    @XmlElement(name = "FromUserName")
    private String fromUserName;
    // 消息创建时间 （整型）
    @XmlElement(name = "CreateTime")
    private Long createTime;
    // 消息类型（text/music/news）
    @XmlJavaTypeAdapter(MsgTypeAdapter.class)
    @XmlElement(name = "MsgType")
    private MsgType msgType;

    // 回复的消息内容
    @XmlJavaTypeAdapter(StringDataAdapter.class)
    @XmlElement(name = "Content")
    private String content;

    @XmlElement(name = "Image")
    private Media image;
    @XmlElement(name = "Voice")
    private Media voice;

    @XmlElement(name = "Video")
    private Media video;

    @XmlElement(name = "Music")
    private Media music;

    @XmlElement(name = "ArticleCount")
    private Integer articleCount;

    @XmlElement(name = "item")
    @XmlElementWrapper(name = "Articles")
    private List<Article> articles;

    public Media getVoice() {
        return voice;
    }

    public void setVoice(Media voice) {
        this.voice = voice;
    }

    public Integer getArticleCount() {
        return articleCount;
    }

    public void setArticleCount(Integer articleCount) {
        this.articleCount = articleCount;
    }

    public List<Article> getArticles() {
        return articles;
    }

    public void setArticles(List<Article> articles) {
        this.articles = articles;
    }

    public Media getVideo() {
        return video;
    }

    public void setVideo(Media video) {
        this.video = video;
    }

    public Media getMusic() {
        return music;
    }

    public void setMusic(Media music) {
        this.music = music;
    }

    public String getToUserName() {
        return toUserName;
    }

    public void setToUserName(String toUserName) {
        this.toUserName = toUserName;
    }

    public String getFromUserName() {
        return fromUserName;
    }

    public void setFromUserName(String fromUserName) {
        this.fromUserName = fromUserName;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public MsgType getMsgType() {
        return msgType;
    }

    public void setMsgType(MsgType msgType) {
        this.msgType = msgType;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public ResponseMessage() {
        this.createTime = System.currentTimeMillis() / 1000;
    }

    public Media getImage() {
        return image;
    }

    public void setImage(Media image) {
        this.image = image;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getCommand() {
        return command;
    }

    public void setCommand(String command) {
        this.command = command;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("ResponseMessage{");
        sb.append("id=").append(id);
        sb.append(", command='").append(command).append('\'');
        sb.append(", toUserName='").append(toUserName).append('\'');
        sb.append(", fromUserName='").append(fromUserName).append('\'');
        sb.append(", createTime=").append(createTime);
        sb.append(", msgType=").append(msgType);
        sb.append(", content='").append(content).append('\'');
        sb.append(", image=").append(image);
        sb.append(", voice=").append(voice);
        sb.append(", video=").append(video);
        sb.append(", music=").append(music);
        sb.append(", articleCount=").append(articleCount);
        sb.append(", articles=").append(articles);
        sb.append('}');
        return sb.toString();
    }
}
